package com.spring.demo.rabbit.listener;

import com.spring.demo.rabbit.QueueConst;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/***
 * @title QueueListener
 * @description: 直接发送到队列， 使用默认的交换器
 * @author baiji
 * @version 1.0.0
 * @create 2023/9/4 9:40
 **/
@Component
public class QueueListener {

    @RabbitListener(queues = QueueConst.SIMPLE_QUEUE)
    public void handler(Message message) {
        String body = new String(message.getBody(), StandardCharsets.UTF_8);
        System.out.println("simple Queue receive msg: " + body);
    }
}
